﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Web;
using System.Web.Mvc;

namespace SystemManager.Controllers
{
    public class SystemController : Controller
    {
        [DllImport("user32.dll")]
        public static extern bool ExitWindowsEx(int DoFlag, int rea);
        internal const int EWX_LOGOFF = 0x00000000;
        internal const int EWX_SHUTDOWN = 0x00000001;
        internal const int EWX_REBOOT = 0x00000002;
        internal const int EWX_FORCE = 0x00000004;
        internal const int EWX_POWEROFF = 0x00000008;
        public ActionResult Shutdown()
        {
            var b = ExitWindowsEx(EWX_SHUTDOWN, 0);
            return Json(b, JsonRequestBehavior.AllowGet);
        }
        public ActionResult Shutdown1()
        {
            ProcessStartInfo ps = new ProcessStartInfo();
            ps.FileName = "shutdown.exe";
            ps.Arguments = "-s -t 1"; //关机，重启的话修改-s 为-t          
            var t = Process.Start(ps);
            return Json(t, JsonRequestBehavior.AllowGet);
        }

    }
}
